// @ts-ignore
import SvgIcon from '@/components/icon/SvgIcon/index.vue';
import PortalInput from '@/components/form/input/PortalInput.vue';
import PortalButton from '@/components/form/button/PortalButton.vue';
import loading from '@/components/lib/loading/Loading.vue';
import createLoadingLikeDirective from '@/components/lib/loading/customLoading.ts';
import { App, createVNode, render } from 'vue';
export { message } from '@/components/lib/message';
export { loading } from '@/components/lib/loading';
// Element Plus
import 'element-plus/theme-chalk/index.css'; // 引入组件样式
import { ElConfigProvider, ElPagination, ElForm, ElFormItem, ElSelect, ElOption, ElDialog } from 'element-plus';
export default {
  install(app: App) {
    app.component('SvgIcon', SvgIcon);
    app.component('PortalInput', PortalInput);
    app.component('PortalButton', PortalButton);
    // 全局注册loading 指令
    app.directive('loading', createLoadingLikeDirective);
    app.component('SvgIcon', SvgIcon);
    app.component('PortalInput', PortalInput);
    app.component('PortalButton', PortalButton);
    // 全局注册loading 指令
    app.directive('loading', createLoadingLikeDirective);
    app.component('ElConfigProvider', ElConfigProvider);
    app.component('ElPagination', ElPagination);
    app.component('ElForm', ElForm);
    app.component('ElFormItem', ElFormItem);
    app.component('ElSelect', ElSelect);
    app.component('ElOption', ElOption);
    app.component('ElDialog', ElDialog);
    // 注册全局loading
    const VNode = createVNode(loading);
    render(VNode, document.body);
    // 给Vue对象全局挂载属性open、close
    app.config.globalProperties.loading = {
      show: VNode.component?.exposed?.open,
      hide: VNode.component?.exposed?.close,
    };
  },
};
